import { http } from '@/utils/http/axios';
// import { func } from 'vue-types';

/**
 * 获取tree菜单列表
 * @param params
 */
export function informationCategoryTree(params?) {
  return http.request({
    url: '/information/categories/tree',
    method: 'GET',
    params,
  });
}

/**
 * 添加菜单
 * @param params
 */
export function addInformationCategory(params?) {
  return http.request({
    url: '/information/categories',
    method: 'POST',
    params,
  });
}

/**
 * 编辑分类
 * @param params
 */
export function editInformationCategory(params?) {
  return http.request({
    url: `/information/categories/${params.id}`,
    method: 'put',
    params,
  });
}

/**
 * 获取分类
 * @param id
 */
export function informationCategoryInfo(id) {
  return http.request({
    url: `/information/categories/${id}`,
    method: 'GET',
  });
}

/**
 * 删除分类
 * @param params
 */
export function deleteInformationCategory(id) {
  return http.request({
    url: `/information/categories/${id}`,
    method: 'DELETE',
  });
}

// 获取信息列表
export function getInformationList(params) {
  return http.request({
    url: `/information`,
    method: 'GET',
    params,
  });
}

// 查询信息[根据id查询]
export function getInformation(id) {
  return http.request({
    url: `/information/${id}`,
    method: 'GET',
  });
}

// 新增信息
export function addInformation(params) {
  return http.request({
    url: `/information`,
    method: 'POST',
    params,
  });
}

// 更新信息
export function editInformation(params) {
  // 从params对象中提取id属性，并将剩余的属性收集到一个新对象中
  const { id, ...restParams } = params;
  return http.request({
    url: `/information/${id}`,
    method: 'PUT',
    params: restParams,
  });
}

// 发布信息
export function publishInformation(id) {
  return http.request({
    url: `/information/${id}/publish`,
    method: 'GET',
  });
}

// 下架信息
export function unpublishInformation(id) {
  return http.request({
    url: `/information/${id}/unpublish`,
    method: 'GET',
  });
}
